package com.bocom.controller;

import com.bocom.config.SpirngMvcConfig;
import com.sun.tools.internal.ws.processor.model.Model;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * Author shenzhifeng
 * Create time  2019/9/23 9:31
 * Description
 * Modifier
 * Reasons
 */
@Slf4j
@Controller
@RequestMapping("/wel")
public class LoginController {

    @GetMapping("/")
    public String index(@SessionAttribute(SpirngMvcConfig.SESSION_KEY)String account, Model model){

        return "wel";
    }

    @PostMapping("/loginVerify")
    public String loginVerify(@RequestBody String username, String password, HttpSession session){

        if (true) {
            session.setAttribute(SpirngMvcConfig.SESSION_KEY, username);
            return "redirect:/wel/wel";
        } else {
            return "redirect:/login";
        }
    }

    @GetMapping("/logout")
    public String logout(HttpSession session){
        session.removeAttribute(SpirngMvcConfig.SESSION_KEY);
        return "";
    }

    @RequestMapping(value={"/login.go"})
    public String userLogin(){
        return "login";
    }


    @RequestMapping(value={"/wel"})
    public String wel(){
        return "wel";
    }

    @RequestMapping(value={"/uploadHtml"})
    public String uploadHtml(){
        return "upload";
    }


    @RequestMapping(value={"/video"})
    public String video(){
        return "video";
    }



}
